﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SwenAssigment
{
    public partial class Log : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            SqlDataSource1.SelectCommand = @"SELECT * FROM [ViewLog] ORDER BY [LoginDateTime] DESC";
            //GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            SqlDataSource1.SelectCommand = @"SELECT * FROM [ViewLog] where UserName = '" + TextBox2.Text + "' ORDER BY [LoginDateTime] DESC";
            //GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
        }

        protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
        {
            if (e.Day.IsOtherMonth)
            {
                e.Day.IsSelectable = false;
                e.Cell.Text = "";
            }
        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            TextBox3.Text = Calendar1.SelectedDate.ToString("dd/M/yyyy");
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            SqlDataSource1.SelectCommand = @"SELECT * FROM [ViewLog] where datediff(day,convert(date, LoginDateTime), convert(date,'" + TextBox3.Text + "',104))=0 ORDER BY [LoginDateTime] DESC";
            //GridView1.DataSource = SqlDataSource1;
            GridView1.DataBind();
        }


    }
}